package com.lnsf.bookstore.system.userLevel.controller;

import com.github.pagehelper.PageInfo;
import com.lnsf.bookstore.system.userLevel.service.UserLevelService;
import com.lnsf.bookstore.system.userLevel.vo.UserLevel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;

@Controller
@RequestMapping("/userLevel")
public class UserLevelController {

    @Autowired
    private UserLevelService userLevelService;

    @RequestMapping("/v_list.do")
    public String list(HttpServletRequest request, ModelMap modelMap){
        return "admin/userLevel/userLevel";
    }


    @RequestMapping("/info/{userId}")
    @ResponseBody
    public Object info(ModelMap modelMap, HttpServletRequest request, @PathVariable("userId") Integer userId){
	/*	User vipuser = sessionProvider.getUser();*/
        Map<String,Object> map = new HashMap<String, Object>();
        UserLevel userLevel = userLevelService.selectById(userId);
        map.put("user",userLevel);
        return  map;
    }

    /**
     * 查看所有列表
     */
    @RequestMapping("/queryAll")
    @ResponseBody
    public Object queryAll(@RequestParam Map<String, Object> params, UserLevel userLevel) {
        PageInfo<UserLevel> pageInfo = userLevelService.selectAll(params,userLevel);
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("page",pageInfo);
        return map;
    }
	
	
}
